/**
 * 消息推送记录管理初始化
 */
var MsgPushLog = {
    id: "MsgPushLogTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
MsgPushLog.initColumn = function () {
    return [
        {field: 'selectItem', radio: true, visible:false},
        {title: '消息ID', field: 'msgId', visible:false, align: 'center', valign: 'middle', sortable: true},
        {title: '归属模块ID', field: 'moduleId', visible:false, align: 'center', valign: 'middle', sortable: true},
        {title: '归属模块名', field: 'moduleName', align: 'center', valign: 'middle', sortable: true},
        {title: '标题', field: 'msgTitle', align: 'center', valign: 'middle', sortable: true},
        {title: '消息内容', field: 'msgContent', align: 'center', valign: 'middle', sortable: true},
        {title: '发送者ID', field: 'sendUserId', visible:false, align: 'center', valign: 'middle', sortable: true},
        {title: '发送者', field: 'sendUserName', align: 'center', valign: 'middle', sortable: true},
        {title: '接受者类型', field: 'receiveType', align: 'center', valign: 'middle', sortable: true,formatter:function(value,row,index){
        	if(value==0){
        		return "全体";
        	}
    		return "用户";
        }},
        {title: '接受者id', field: 'receiveId', visible:false, align: 'center', valign: 'middle', sortable: true},
        {title: '接受者', field: 'receiveName', align: 'center', valign: 'middle', sortable: true},
        {title: '推送类型', field: 'pushType', align: 'center', valign: 'middle', sortable: true,formatter:function(value,row,index){
    		return row.pushTypeName;
        }},
        {title: '推送时间', field: 'pushTime', align: 'center', valign: 'middle', sortable: true},
        {title: '推送尝试次数', field: 'pushNumber', align: 'center', valign: 'middle', sortable: true},
        ];
};

/**
 * 查询消息推送记录列表
 */
MsgPushLog.search = function () {
    var queryData = {};
    queryData['pushType'] = $("input[name='pushType']").val();
    queryData['pushNumber'] = $("#pushNumber").val();
    queryData['startDate'] = $("#startDate").val();
    queryData['endDate'] = $("#endDate").val();
    MsgPushLog.table.refresh({query: queryData});
};

$(function () {
    var defaultColunms = MsgPushLog.initColumn();
    var table = new BSTable(MsgPushLog.id, Sys.backendPath + "/msgcenter/pushlog/list", defaultColunms);
    table.setPaginationType("server");
    MsgPushLog.table = table.init();
});
